import { useEffect, useState } from 'react';
import { Input, Button } from 'antd';

export default function Manage(params) {
  const [index, setIndex] = useState();
  useEffect(() => {
    window.scratchpad.onUpdateCounter((index) => {
      setIndex(index);
    });
  }, []);

  const onSave = (e) => {
    window.scratchpad.saveContent(e.target.value);
  };

  return (
    <div>
      <Input.TextArea onChange={onSave} />
      <Button
        onClick={async () => {
          const res = await window.scratchpad.openFile();
          console.log(res);
        }}
      >
        打开文件: {index}
      </Button>
    </div>
  );
}
